﻿Public Class ven_anal_resisestt

    

   

    
    
    Private Sub btn_ven_analcargas_graf_Click(sender As Object, e As EventArgs) Handles btn_ven_analcargas_graf.Click
        ven_analcargas_graf.Show()

    End Sub

    
    
    Private Sub btn_calculardminre_Click(sender As Object, e As EventArgs) Handles btn_calculardminre.Click
        Dim n3 As Integer = dgvdiamestt.Rows.Add()


        fsre = Convert.ToSingle(txt_fsre.Text)
        ye = Convert.ToSingle(txt_ye.Text)
        If esa = 1 And ecvd = 0 And ecvi = 0 Then 'MODELO SIMPLEMENTE APOYADO

            If yc1 > 0 And yc2 = 0 Then 'con una carga
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye <= yt Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = 0
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = 0
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 Then 'con dos cargas
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye <= yt Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
            End If

        End If





        If ecvd = 1 And esa = 0 And ecvi = 0 Then 'MODELO CON VOLADIZO DERECHO

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano
                'debemos analizar cuatro puntos del árbol: yc1, yc2, yr2, yc3.
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then 'hastaacaaaaaaaaaaaaaaa 14 11 14
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If







        If ecvi = 1 And esa = 0 And ecvd = 0 Then 'MODELO CON VOLADIZO IZQUIERDO !! 14 11 14

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'con una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
            End If


            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                    mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If



        If ecdv = 1 And ecvd = 0 And esa = 0 And ecvi = 0 Then 'MODELO CON DOS VOLADIZOS

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                    myre = -m1y - m3y - m5y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                        myre = -m1y - m3y - m5y
                    End If
                End If
            End If

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 = 0 And yc6 = 0 Then 'una carga en primer vano y segundo vano  ... ninguna carga en tercer vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
            End If

            If yc1 = 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'no carga en primer vano, una carga en segundo vano y tercer vano 
                If ye >= 0 And ye < yr1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1)
                    mzre = r1x * (ye - yr1)
                    myre = 0
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                    myre = -m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                    myre = -m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                    mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                    myre = -m1y - m5y
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                        mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                        myre = -m1y - m5y
                    End If
                End If
            End If

        End If






        mrre = Math.Sqrt(mxre * mxre + mzre * mzre)
        dminre = (((16 * fsre) / (3.141592 * sf)) * Math.Sqrt(4 * mrre * mrre + 3 * myre * myre)) ^ (1 / 3)

        dgvdiamestt.Rows.Item(n3).Cells(0).Value = dminre

        

       


    End Sub

    
    Private Sub izq_estt_Click(sender As Object, e As EventArgs) Handles izq_estt.Click
        sidee = 0

    End Sub

    Private Sub der_estt_Click(sender As Object, e As EventArgs) Handles der_estt.Click
        sidee = 1
    End Sub

    
    Private Sub btn_calcularfs_Click(sender As Object, e As EventArgs) Handles btn_calcularfs.Click
        Dim n4 As Integer = dgvfsfluencia.Rows.Add()


        dminre = Convert.ToSingle(txt_drestt.Text)
        ye = Convert.ToSingle(txt_ye.Text)
        If esa = 1 And ecvd = 0 And ecvi = 0 Then 'MODELO SIMPLEMENTE APOYADO

            If yc1 > 0 And yc2 = 0 Then 'con una carga
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye <= yt Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = 0
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = 0
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 Then 'con dos cargas
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye <= yt Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
            End If

        End If





        If ecvd = 1 And esa = 0 And ecvi = 0 Then 'MODELO CON VOLADIZO DERECHO

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano
                'debemos analizar cuatro puntos del árbol: yc1, yc2, yr2, yc3.
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then 'hastaacaaaaaaaaaaaaaaa 14 11 14
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If







        If ecvi = 1 And esa = 0 And ecvd = 0 Then 'MODELO CON VOLADIZO IZQUIERDO !! 14 11 14

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'con una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
            End If


            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                    mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If


        If ecdv = 1 And ecvd = 0 And esa = 0 And ecvi = 0 Then 'MODELO CON DOS VOLADIZOS

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                    myre = -m1y - m3y - m5y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                        myre = -m1y - m3y - m5y
                    End If
                End If
            End If

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 = 0 And yc6 = 0 Then 'una carga en primer vano y segundo vano  ... ninguna carga en tercer vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
            End If

            If yc1 = 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'no carga en primer vano, una carga en segundo vano y tercer vano 
                If ye >= 0 And ye < yr1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1)
                    mzre = r1x * (ye - yr1)
                    myre = 0
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                    myre = -m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                    myre = -m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                    mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                    myre = -m1y - m5y
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                        mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                        myre = -m1y - m5y
                    End If
                End If
            End If

        End If





        mrre = Math.Sqrt(mxre * mxre + mzre * mzre)

        fsre = sf / Math.Sqrt((32 * mrre / (3.141592 * (dminre) ^ 3)) ^ 2 + 3 * (16 * myre / (3.141592 * (dminre) ^ 3)) ^ 2)

        dgvfsfluencia.Rows.Item(n4).Cells(0).Value = fsre
        


    End Sub

    
    Private Sub btn_vercargasestt_Click(sender As Object, e As EventArgs) Handles btn_vercargasestt.Click
        Dim n5 As Integer = dgvcargasestt.Rows.Add()

        ye = Convert.ToSingle(txt_ye.Text)
        If esa = 1 And ecvd = 0 And ecvi = 0 And ecdv = 0 Then 'MODELO SIMPLEMENTE APOYADO

            If yc1 > 0 And yc2 = 0 Then 'con una carga
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye <= yt Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = 0
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = 0
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 Then 'con dos cargas
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye <= yt Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
            End If

        End If





        If ecvd = 1 And esa = 0 And ecvi = 0 And ecdv = 0 Then 'MODELO CON VOLADIZO DERECHO

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano
                'debemos analizar cuatro puntos del árbol: yc1, yc2, yr2, yc3.
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yr2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -(m1y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then 'hastaacaaaaaaaaaaaaaaa 14 11 14
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -(m1y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = r1z * ye
                    mzre = r1x * ye
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = r1z * ye + c1z * (ye - yc1) - m1x
                    mzre = r1x * ye + c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr2 Then
                    mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr2 And ye < yc3 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = r1z * ye
                        mzre = r1x * ye
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + c1z * (ye - yc1) - m1x
                        mzre = r1x * ye + c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * ye + r2z * (ye - yr2) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * ye + r2x * (ye - yr2) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If







        If ecvi = 1 And esa = 0 And ecvd = 0 And ecdv = 0 Then 'MODELO CON VOLADIZO IZQUIERDO !! 14 11 14

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 Then 'con una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                    myre = -m1y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1)) - (m1x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1)) + (m1z)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
            End If


            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 = 0 Then 'con dos cargas en primer vano y una carga en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
            End If


            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 > 0 Then 'con una carga en primer vano y dos cargas en segundo vano (tres cargas)
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                    mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                    myre = -m1y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                    myre = -m1y - m3y
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                    myre = -(m1y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1)) - (m1x) + r1z * (ye - yr1)
                        mzre = c1x * (ye - yc1) + m1z + r1x * (ye - yr1)
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3)) - (m1x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3)) + (m1z + m3z)
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m3z + m4z)
                        myre = -(m1y + m3y + m4y)
                    End If
                End If
            End If

            If yc1 > 0 And yc2 > 0 And yc3 > 0 And yc4 > 0 Then 'con dos cargas en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yc2 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yc2 And ye < yr1 Then
                    mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                    myre = -m1y - m2y
                End If
                If ye > yc3 And ye < yc4 Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                    myre = -(m1y + m2y + m3y)
                End If
                If ye > yc4 And ye <= yt Then
                    mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                    mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                    myre = -(m1y + m2y + m3y + m4y)
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2)) - (m1x + m2x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2)) + (m1z + m2z)
                        myre = -m1y - m2y
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                End If
                If ye = yc4 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3)) - (m1x + m2x + m3x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3)) + (m1z + m2z + m3z)
                        myre = -(m1y + m2y + m3y)
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1) + (c1z * (ye - yc1) + c2z * (ye - yc2) + c3z * (ye - yc3) + c4z * (ye - yc4)) - (m1x + m2x + m3x + m4x)
                        mzre = r1x * (ye - yr1) + (c1x * (ye - yc1) + c2x * (ye - yc2) + c3x * (ye - yc3) + c4x * (ye - yc4)) + (m1z + m2z + m3z + m4z)
                        myre = -(m1y + m2y + m3y + m4y)
                    End If
                End If
            End If

        End If


        If ecdv = 1 And ecvd = 0 And esa = 0 And ecvi = 0 Then 'MODELO CON DOS VOLADIZOS

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'una carga en cada vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                    myre = -m1y - m3y - m5y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x - m5x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z + m5z
                        myre = -m1y - m3y - m5y
                    End If
                End If
            End If

            If yc1 > 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 = 0 And yc6 = 0 Then 'una carga en primer vano y segundo vano  ... ninguna carga en tercer vano
                If ye >= 0 And ye < yc1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yc1 And ye < yr1 Then
                    mxre = c1z * (ye - yc1) - m1x
                    mzre = c1x * (ye - yc1) + m1z
                    myre = -m1y
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                    mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                    myre = -m1y
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye > yr2 And ye <= yt Then
                    mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                    mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                    myre = -m1y - m3y
                End If
                If ye = yc1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) - m1x
                        mzre = c1x * (ye - yc1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + r1z * (ye - yr1) - m1x
                        mzre = c1x * (ye - yc1) + r1x * (ye - yr1) + m1z
                        myre = -m1y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                    If sidee = 1 Then
                        mxre = c1z * (ye - yc1) + c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m1x - m3x
                        mzre = c1x * (ye - yc1) + c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m1z + m3z
                        myre = -m1y - m3y
                    End If
                End If
            End If

            If yc1 = 0 And yc2 = 0 And yc3 > 0 And yc4 = 0 And yc5 > 0 And yc6 = 0 Then 'no carga en primer vano, una carga en segundo vano y tercer vano 
                If ye >= 0 And ye < yr1 Then
                    mxre = 0
                    mzre = 0
                    myre = 0
                End If
                If ye > yr1 And ye < yc3 Then
                    mxre = r1z * (ye - yr1)
                    mzre = r1x * (ye - yr1)
                    myre = 0
                End If
                If ye > yc3 And ye < yr2 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                    myre = -m3y
                End If
                If ye > yr2 And ye < yc5 Then
                    mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                    mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                    myre = -m3y
                End If
                If ye > yc5 And ye <= yt Then
                    mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                    mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                    myre = -m1y - m5y
                End If
                If ye = yr1 Then
                    If sidee = 0 Then
                        mxre = 0
                        mzre = 0
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                End If
                If ye = yc3 Then
                    If sidee = 0 Then
                        mxre = r1z * (ye - yr1)
                        mzre = r1x * (ye - yr1)
                        myre = 0
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yr2 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                End If
                If ye = yc5 Then
                    If sidee = 0 Then
                        mxre = c3z * (ye - yc3) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x
                        mzre = c3x * (ye - yc3) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z
                        myre = -m3y
                    End If
                    If sidee = 1 Then
                        mxre = c3z * (ye - yc3) + c5z * (ye - yc5) + r1z * (ye - yr1) + r2z * (ye - yr2) - m3x - m5x
                        mzre = c3x * (ye - yc3) + c5x * (ye - yc5) + r1x * (ye - yr1) + r2x * (ye - yr2) + m3z + m5z
                        myre = -m1y - m5y
                    End If
                End If
            End If

        End If

























        'jujuju




        dgvcargasestt.Rows.Item(n5).Cells(0).Value = mxre
        dgvcargasestt.Rows.Item(n5).Cells(1).Value = mzre
        dgvcargasestt.Rows.Item(n5).Cells(2).Value = myre
    End Sub

    Private Sub btn_helpresisestt_Click(sender As Object, e As EventArgs) Handles btn_helpresisestt.Click
        ven_helpresisestt.Show()
    End Sub
End Class